home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / sed15x.zip / SED.LST < prev   
File List  |  1991-09-22  |  25KB  |  661 lines

  1.  
  2.  
  3.  
  4.    SED(1)                      USER DOCUMENTATION                       SED(1)
  5.  
  6.  
  7.    NAME
  8.       sed - the stream editor
  9.  
  10.    SYNOPSIS
  11.       sed [-n] [-g] [-e script] [-f sfilename] [filename ]
  12.  
  13.    DESCRIPTION
  14.    sed reads each filename line by line, edits each line according to a script
  15.    of commands  as specified  by the  -e and -f arguments  and then copies the
  16.    edited line to the standard output.
  17.  
  18.    OPTIONS
  19.    The -e  option supplies  a single  edit command  from the next argument; if
  20.    there are  several of  these they  are executed in the order in  which they
  21.    appear. If  there is  just one  -e option  and no -f's, the -e  flag may be
  22.    omitted. An  -f option causes commands to be taken from the file sfilename;
  23.    if there  are several   of these they are  executed in the order  in  which
  24.    they appear;  -e and  -f commands may be mixed. The script or sfilename can
  25.    be adjacent  to the  -e or  -f or  can be  the next argument on the command
  26.    line.   The -g  option causes sed to act as though every substitute command
  27.    in the  following script  has a  g suffix.   The  -n option  suppresses the
  28.    default output.
  29.  
  30.    SCRIPTS
  31.    A script  consists of  one or  more sed  commands of  the  following  form:
  32.         [address[,address]] function [arguments]     
  33.    Normally sed cyclically copies a line of input into a  current text buffer,
  34.    then applies  in sequence all commands whose addresses select that line and
  35.    then copies  the buffer  to standard  output and clears the buffer.  The -n
  36.    option suppresses normal output so that only commands which do output (e.g.
  37.    p) cause  any writing  to occur.   Also,  some commands (n, N) do their own
  38.    line reads,  and some  others (o, d, D) cause all commands following in the
  39.    script to  be skipped  (the D  command also  suppresses the clearing of the
  40.    current text  buffer that  would normally  occur before  the  next  cycle).
  41.    There is  also a  second buffer (called the 'hold space' that can be copied
  42.    or appended to or from or swapped with the current text buffer.
  43.  
  44.    ADDRESSES
  45.    An address  is: a  decimal number  (which matches  that numbered line where
  46.    line numbers start at 1 and run cumulatively across files), or a '$' (which
  47.    matches the last line of input), or a '/regular expression/' (which matches
  48.    any line  satisfying the expression. The following rules govern the address
  49.    matching:
  50.  
  51.       * A command line with no addresses selects every input line.
  52.  
  53.       * A command line with one address selects every input line that  matches
  54.         that address.
  55.  
  56.       * A command line with two addresses selects the inclusive range from the
  57.         first input line that matches the first address up to and including
  58.         the next input that matches the second. (If the second address is a
  59.         number less than or equal to the line number first  selected, only one
  60.         line is selected.) Once the second address is matched sed starts
  61.  
  62.  
  63.  
  64.    h**2 Documentation          21 September 1991                             1
  65.  
  66.  
  67.  
  68.  
  69.  
  70.    SED(1)                      USER DOCUMENTATION                       SED(1)
  71.  
  72.  
  73.         looking for the first one again; thus, any number of these ranges will
  74.         be matched.
  75.  
  76.       * The second address may be in the form of '+number'.  This means that
  77.         the command will stay selected for number lines after the first
  78.         address is satisfied.
  79.  
  80.       * \?regular expression? where ? is any character is identical to
  81.         /regular expression/.
  82.  
  83.       * The negation operator '!' preceding a function makes that function
  84.         apply to every line not selected by the address(es).
  85.  
  86.    FUNCTIONS
  87.    In the  following list  of  functions,  the  maximum  number  of  addresses
  88.    permitted for  each function  is indicated  in parentheses.    An  argument
  89.    denoted 'text' consists of one or more lines,  with all but the last ending
  90.    with '\' to hide the newline. A command with this type argument must be the
  91.    last on  any command  line or  -e argument. Otherwise multiple commands may
  92.    appear on  a line  separated by  ';' characters.   A  command  may  have  a
  93.    trailing comment  indicated by  a '#' character. Comment lines begin with a
  94.    '#'.   Backslashes in  text are  treated as  described in 'escape sequences
  95.    below; they   may  be  used  to  protect  initial  whitespace  against  the
  96.    stripping that  is done  on every  line of the script.  An argument denoted
  97.    'label', 'rfile'  or 'wfile'  (which specify  labels or file names)  is not
  98.    processed for  'escape sequences'.  Therefore a  ';' or  '#' terminates the
  99.    label or  file name. This simplifies entering DOS style paths. Each 'wfile'
  100.    is created  before processing  begins.   There can  be at  most 10 distinct
  101.    'wfile' arguments.
  102.  
  103.    (1) a text      Append the 'text' on output before reading the next input
  104.                    line.
  105.  
  106.    (2) b [label]   Branch to the ':' command with the given 'label'.  If no
  107.                    'label' is  given, branch to the end of the script.
  108.  
  109.    (2) c text      Change lines by deleting the current text buffer and at the
  110.                    end of the address range, place 'text' on the output.
  111.                    Start the next input cycle.
  112.  
  113.    (2) d           Delete the current text buffer. Start the next input cycle.
  114.  
  115.    (2) D           Delete the first line of the current text buffer (all
  116.                    characters up to the first newline). Start the next input
  117.                    cycle.
  118.  
  119.    (2) g           Replace the contents of the current text buffer with the
  120.                    contents  of the hold space.
  121.  
  122.    (2) G           Append the contents of the hold space to the current text
  123.                    buffer.
  124.  
  125.    (2) h           Copy the current text buffer into the hold space.
  126.  
  127.  
  128.  
  129.  
  130.    h**2 Documentation          21 September 1991                             2
  131.  
  132.  
  133.  
  134.  
  135.  
  136.    SED(1)                      USER DOCUMENTATION                       SED(1)
  137.  
  138.  
  139.    (2) H           Append a copy of the current text buffer to the hold space.
  140.  
  141.    (1) i text      Insert the 'text' on the standard output.
  142.  
  143.    (2) l [w[file]] List current text buffer on standard output or to a file if
  144.                    the  -w option follows. Non ASCII printable characters are
  145.                    expanded as shown in the 'escape sequence' section below.
  146.  
  147.    (2) n           Copy the current text buffer to standard output. Read the
  148.                    next line of input into it. The current line number
  149.                    changes.
  150.  
  151.    (2) N           Append the next line of input to the current text buffer,
  152.                    inserting an embedded newline between the two. The current
  153.                    line number changes.
  154.  
  155.    (2) p           Copy the current text buffer to the standard output.
  156.  
  157.    (2) P           Copy the first line of the current text buffer (all
  158.                    characters up to the first newline) to standard output.
  159.  
  160.    (1) q           Quit. Perform any pending outputs (a or r commands) and
  161.                    terminate sed.
  162.  
  163.    (1) r rfile     Read the contents of 'rfile'. Place them on the output
  164.                    before reading the next input line.
  165.  
  166.    (2) s /regular expression/replacement/flags
  167.                    Substitute the 'replacement' for instances of the 'regular
  168.                    expression' in the current text buffer.  Any character may
  169.                    be used instead of '/'. In the 'regular expression' and in
  170.                    the 'replacement' text \1 - \9 are used to indicate the nth
  171.                    subexpression indicated by a '\(...\)' expression in the
  172.                    'regular expression'.  In the replacement text an & may be
  173.                    used to indicate the entire matched expression. If the
  174.                    replacement text consists only of the a single '%'
  175.                    character, then a copy of the replacement text for the
  176.                    previous s command is used as the replacement text for this
  177.                    co